package com.xhorse.lockplatform.manage.controller;

import com.xhorse.lockplatform.comm.model.BaseQuery;
import com.xhorse.lockplatform.comm.mvc.AbstractListController;
import com.xhorse.lockplatform.comm.util.Paginator;
import com.xhorse.lockplatform.model.pojo.XhUsingLogPojo;
import com.xhorse.lockplatform.service.impl.UsingLogServiceImpl;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

@Controller
@RequestMapping("usingLog/usingLogResult")
public class UsingLogController extends AbstractListController<XhUsingLogPojo,
        UsingLogServiceImpl, UsingLogController.FeedBackInfoQuery> {

    @Resource
    public void setUsingLogServiceImpl(UsingLogServiceImpl usingLogService) {
        this.service = usingLogService;
    }

    public UsingLogController() {
        super("FeedBack/usingLogResult");
    }

    @Override
    protected boolean preList(int page, Paginator paginator, FeedBackInfoQuery query, Model model) {
        this.data = service.getUsingLog(paginator, query.getType());
        return super.preList(page, paginator, query, model);
    }

    // 查询参数bean
    public static class FeedBackInfoQuery extends BaseQuery {
        private int type;
        private String customerId;
        private String terminal;
        private int success;

        public void setType(int type) {
            this.type = type;
            this.addItem("type", type);
        }

        public void setCustomerId(String customerId) {
            this.customerId = customerId;
            this.addItem("customerId", customerId);
        }

        public void setTerminal(String terminal) {
            this.terminal = terminal;
            this.addItem("terminal", terminal);
        }

        public void setSuccess(int success) {
            this.success = success;
            this.addItem("success", success);
        }

        public int getType() {
            return type;
        }

        public String getCustomerId() {
            return customerId;
        }

        public String getTerminal() {
            return terminal;
        }

        public int getSuccess() {
            return success;
        }
    }
}
